// pages/detail/detail.js
var sliderWidth = 96;
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    allList:[],
    tabs: ["推荐", "流行", "精品", "华语", "欧美"],
    activeIndex: 0,
    sliderOffset: 0,
    sliderLeft: 0
  },
  gotoSongList(event){
    var id=event.currentTarget.dataset.id
    console.log(id);
    var geDanId=this.data.allList[id].id
    wx.navigateTo({
      url: '../songList/songList?id='+geDanId,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var allList=wx.getStorageSync('allList')
    this.setData({
      allList:allList
    })
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2,
          sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex
        });
      }
    });
    that.setData({
      activeIndex: options.activeIndexData
    })
   },
  tabClick : function (e) {
    this.setData({
      sliderOffset: e.currentTarget.offsetLeft,
      activeIndex: e.currentTarget.id
    })
  },

  
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})